Nested VMX: fix error paths in emulation of VMLAUNCH and VMRESUME.
authorTim Deegan <Tim.Deegan@citrix.com>
Tue, 26 Jul 2011 16:00:25 +0000 (17:00 +0100)
committerTim Deegan <Tim.Deegan@citrix.com>
Tue, 26 Jul 2011 16:00:25 +0000 (17:00 +0100)
These instructions don't fault on bad VMCS pointers, they set bits in
RFLAGS and continue execution.

Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
xen/arch/x86/hvm/vmx/vvmx.c

index 942fd49d135070595bc7ace6ca61fb68fffb6957..889f3d5af1b1e902e5225b332d4bc7e43990cd86 100644 (file)
@@ -1070,11 +1070,17 @@ int nvmx_handle_vmresume(struct cpu_user_regs *regs)
     int launched;
     struct vcpu *v = current;
 
+    if ( vcpu_nestedhvm(v).nv_vvmcxaddr == VMCX_EADDR )
+    {
+        vmreturn (regs, VMFAIL_INVALID);
+        return X86EMUL_OKAY;        
+    }
+
     launched = __get_vvmcs(vcpu_nestedhvm(v).nv_vvmcx,
                            NVMX_LAUNCH_STATE);
     if ( !launched ) {
        vmreturn (regs, VMFAIL_VALID);
-       return X86EMUL_EXCEPTION;
+       return X86EMUL_OKAY;
     }
     return nvmx_vmresume(v,regs);
 }
@@ -1085,11 +1091,17 @@ int nvmx_handle_vmlaunch(struct cpu_user_regs *regs)
     int rc;
     struct vcpu *v = current;
 
+    if ( vcpu_nestedhvm(v).nv_vvmcxaddr == VMCX_EADDR )
+    {
+        vmreturn (regs, VMFAIL_INVALID);
+        return X86EMUL_OKAY;        
+    }
+
     launched = __get_vvmcs(vcpu_nestedhvm(v).nv_vvmcx,
                            NVMX_LAUNCH_STATE);
     if ( launched ) {
        vmreturn (regs, VMFAIL_VALID);
-       rc = X86EMUL_EXCEPTION;
+       return X86EMUL_OKAY;
     }
     else {
         rc = nvmx_vmresume(v,regs);